﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DrawChartImage;
using System.Drawing;

namespace EnvironmentManagerSystem.A
{
    public partial class BaoGaoShuBiaoS : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string tb1 = Request.QueryString["ShouLi1"];
                string tb2 = Request.QueryString["ShouLi2"];
                //NEW出柱形图片的对象
                ChartImage chartImage = new ChartImage();
                //设置图片的属性
                chartImage.ImageAtt.CaptionColor = Color.Blue;
                chartImage.ImageAtt.BorderDistance = 5;
                chartImage.ImageAtt.CaptionFont = new Font("宋体", 15);
                chartImage.ImageAtt.CPlace = CaptionPlace.Left;
                chartImage.ImageAtt.Caption = "报告书/表(统计)";
                chartImage.ImageAtt.LeftGraduationValue = 5;
                //设置图片中的柱形
                chartImage.ChartCount = 1;
                chartImage.ChartItems.Add(new Chart());
                //柱形的标题文字
                int BaoGaoShuGeShu = 0;
                string strPJ = "";
                if (tb1 != "" && tb2 != "")//搜索开始时间，搜索结束时间
                    strPJ += " AND xiangmushoulishijian between '" + tb1 + "' and '" + tb2 + "'";
                if (tb1 == null || tb1 == "" || tb2 == null || tb2 == "")
                    BaoGaoShuGeShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_developprojectbasicinfo WHERE Report='报告书'"));
                else
                    BaoGaoShuGeShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_developprojectbasicinfo WHERE Report='报告书' AND 1=1 " + strPJ + " "));
                chartImage.ChartItems[0].Caption = BaoGaoShuGeShu.ToString();
                chartImage.ChartItems[0].CaptionFont = new Font("宋体", 12);
                chartImage.ChartItems[0].BorderColor = Color.Blue;
                chartImage.ChartItems[0].SetChartColor(Color.White, Color.SeaGreen);
                //柱形的高度
                chartImage.ChartItems[0].Height = BaoGaoShuGeShu * 5;
                //柱形底部文字
                chartImage.ChartItems[0].BottomText = "报告书";
                //柱形的标题文字
                int BaoGaoBiaoGeShu = 0;
                if (tb1 == null || tb1 == "" || tb2 == null || tb2 == "")
                    BaoGaoBiaoGeShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_developprojectbasicinfo WHERE Report='一般报告表'"));
                else
                    BaoGaoBiaoGeShu = Convert.ToInt32(BLL.HuanPingService.GetCount("SELECT COUNT(*) FROM tbs001_developprojectbasicinfo WHERE Report='一般报告表' AND 1=1 " + strPJ + " "));
                chartImage.ChartItems[1].Caption = BaoGaoBiaoGeShu.ToString();
                chartImage.ChartItems[1].CaptionFont = new Font("宋体", 12);
                chartImage.ChartItems[1].BorderColor = Color.Blue;
                chartImage.ChartItems[1].SetChartColor(Color.White, Color.SeaGreen);
                chartImage.ChartItems[1].Height = BaoGaoBiaoGeShu * 5;
                chartImage.ChartItems[1].BottomText = "一般报告表";

                //chartImage.ChartItems[0].SetChartColor(Color.White, Color.OrangeRed);
                //chartImage.ChartItems[1].SetChartColor(Color.White,Color.SeaGreen);
                //chartImage.ChartItems[1].BorderColor = Color.Black;
                //chartImage.ChartItems[0].Caption = "圆柱体";
                //chartImage.ChartItems[0].CaptionFont = new Font("华文行楷", 12);
                //chartImage.ChartItems[0].CaptionColor = Color.Green;
                //chartImage.ChartItems[0].BorderColor = Color.Blue;
                //chartImage.ChartItems[0].SetChartColor(Color.White, Color.GreenYellow);
                //chartImage.ChartItems[0].Height = 240;
                //chartImage.ChartItems[3].SetChartColor(Color.White, Color.DarkOrchid);
                //chartImage.ChartItems[4].SetChartColor(Color.Yellow, Color.YellowGreen);
                //chartImage.ChartItems[4].BottomText = "底部文本";
                //chartImage.ChartItems[3].BottomText = "底部文本";
                //chartImage.ChartItems[3].BottomTextColor = Color.Green;

                //设置图片中的虚线
                //chartImage.BrokenLineItems.Add(new BrokenLine(300));
                //chartImage.BrokenLineItems.Add(new BrokenLine(250));
                //chartImage.BrokenLineItems.Add(new BrokenLine(200));
                //chartImage.BrokenLineItems[0].TextPlace = TextPlace.Down;
                //chartImage.BrokenLineItems[0].TextX = 300;
                //chartImage.BrokenLineItems[1].TextPlace = TextPlace.Bosom;
                //chartImage.BrokenLineItems[1].TextColor = Color.Blue;
                //chartImage.BrokenLineItems[1].TextX = 100;
                //chartImage.BrokenLineItems[2].TextPlace = TextPlace.Up;
                //chartImage.BrokenLineItems[2].BrokenLineColor = Color.Red;
                //chartImage.BrokenLineItems[2].DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

                //设置底部文字
                //chartImage.ChartItems[0].BottomText = "报告表";
                //设置柱形的标题文字
                //chartImage.ChartItems[0].Caption = "48";
                //设置柱形的高度
                //chartImage.ChartItems[0].Height = 48 * 5;
                //设置标题文字的颜色
                //chartImage.ChartItems[0].CaptionColor = Color.Green;              
                //标题标题文字的字体
                //chartImage.ChartItems[0].CaptionFont = new Font("宋体", 12);
                //设置柱形的颜色
                //chartImage.ChartItems[0].SetChartColor(Color.White, Color.GreenYellow);
                //设置柱形的边框颜色
                //chartImage.ChartItems[0].BorderColor = Color.Blue;
                //获得图片
                Bitmap bmp = chartImage.GetImage();
                Response.ContentType = "Image/jpeg";
                bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                Response.End();
            }
        }
    }
}